package com.example.gobang.congig;

import com.example.gobang.api.GameApi;
import com.example.gobang.api.MatchApi;
import com.example.gobang.api.TestAoi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor;

@Configuration
@EnableWebSocket
public class webSocketConfig implements WebSocketConfigurer {
    @Autowired
    private TestAoi testAoi;
    @Autowired
    private MatchApi matchApi;
    @Autowired
    private GameApi gameApi;
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(testAoi,"/test");
        registry.addHandler(matchApi,"**/findMatch/**").addInterceptors(new HttpSessionHandshakeInterceptor());
     registry.addHandler(gameApi,"/game").addInterceptors(new HttpSessionHandshakeInterceptor());
    }
}
